<template>
  <div class="dashboard-container">
    首页
    <e-charts class="chart" :option="option"></e-charts>
  </div>
</template>

<script>
import { mapState, mapActions } from 'vuex';

export default {
  computed: {
    ...mapState('dashboard', ['lineData']), // { time: '12:00', count: 500 }[]
    option () {
      return {
        xAxis: {
          type: 'category',
          data: this.lineData.map(d => d.time),
          axisLabel: {
            rotate: 90,
          },
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            data: this.lineData.map(d => d.count),
            type: 'line'
          }
        ],
      };
    },
  },
  methods: {
    ...mapActions('dashboard', ['updateLineData']),
  },
  created () {
    this.updateLineData();
  },
}
</script>

<style lang="scss" scoped>
.chart {
  height: 400px;
}
</style>
